package com.dzzw.Servlet.MessageServlet;

import com.dzzw.Dao.MessageDao;
import com.dzzw.Model.Message;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/View/MessageAddServlet")
public class MessageAddServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
    MessageDao messageDao = new MessageDao();
    public MessageAddServlet(){
        super();
    }
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        int employee_id = Integer.parseInt(request.getParameter("employee_id"));
        String message_info = request.getParameter("message_info");
        Message message =new Message();
        message.setEmployee_id(employee_id);
        message.setMessage_info(message_info);
        messageDao.MessageAdd(message);
        response.sendRedirect("/View/SelectAllMessage.jsp");
    }
}
